package com.lyh.service;

import com.lyh.dao.BookDao;
import com.lyh.pojo.Book;
import com.lyh.pojo.BookVo;
import com.lyh.pojo.PageBean;

import java.sql.SQLException;
import java.util.List;

/**
 * 功能
 * 作者：lyh
 * 日期：2024/8/8 10:50
 */
public class BookService {
    BookDao bookDao = new BookDao();

    public PageBean<BookVo> findAll(int pageNum, int pageSize) {
        try {
            return bookDao.findAll(pageNum,pageSize);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    public void addBook(Book book) {
        try {
            bookDao.addBook(book);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public PageBean<BookVo> like(int pageNum, int pageSize, String likeName) {
        try {
            return bookDao.like(pageNum,pageSize,likeName);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    public void deleteById(int id) {
        try {
            bookDao.deleteById(id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public Book findById(int id) {
        try {
            return bookDao.findById(id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    public void updateBook(Book book) {
        try {
            bookDao.updateBook(book);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
